package com.mediastory.spsserver.verMngr.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.mediastory.spsserver.verMngr.dao.VerMngrDao;
import com.mediastory.spsserver.verMngr.domain.VerMngr;

/**
 * @author Jaewon Choi
 */

@Repository
public class VerMngrDaoImpl extends SqlSessionDaoSupport implements VerMngrDao {

	public VerMngrDaoImpl() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public List<VerMngr> SelectList(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		Integer page = (Integer)condition.get("page");
		Integer maxnum = (Integer)condition.get("maxnum");
		
		List<VerMngr> result = null;
		if(page != null && maxnum != null){
			RowBounds rb = new RowBounds(page, maxnum);
			result = getSqlSession().selectList("VerMngr.selectList", condition, rb);
		}else{
			result = getSqlSession().selectList("VerMngr.selectList", condition);
		}
		
		return result;
	}
	
	@Override
	public Integer SelectListTotalCnt(Map<String, Object> condition)
			throws Exception {
		// TODO Auto-generated method stub
		Integer result = getSqlSession().selectOne("VerMngr.selectListTotalCnt", condition);
		return result;
	}

	@Override
	public VerMngr select(Integer idx) throws Exception {
		// TODO Auto-generated method stub
		VerMngr result = (VerMngr)(getSqlSession().selectOne("VerMngr.select", idx)); 
		return result;
	}

	@Override
	public VerMngr insert(VerMngr verMngr) throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().insert("VerMngr.insert", verMngr);
		return verMngr;
	}

	@Override
	public VerMngr update(VerMngr verMngr) throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().update("VerMngr.update", verMngr);
		return verMngr;
	}

	@Override
	public int delete(Map<String, Object> condition) throws Exception {
		// TODO Auto-generated method stub
		int result = getSqlSession().update("VerMngr.delete", condition);
		return result;
	}

}
